<template>
	<view class="login-page">
		<view class="login-box">
			<view class="title-text">手机号：</view>
			<uni-easyinput v-model="phoneNum" type="number" :trim="true" primaryColor="#ffd589" :maxlength="11" placeholder="请输入手机号"></uni-easyinput>
			<view class="title-text">旧密码：</view>
			<uni-easyinput v-model="oldPwd" type="text" :trim="true" primaryColor="#ffd589" :maxlength="11" placeholder="请输入旧密码"></uni-easyinput>
			<view class="title-text">新密码：</view>
			<uni-easyinput v-model="newPwd" type="text" :trim="true" primaryColor="#ffd589" :maxlength="11" placeholder="请输入新密码"></uni-easyinput>
		</view>
		<view class="login-btn " @click="submitEvent">确认</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phoneNum:'',
				oldPwd:'',
				newPwd:'',
			};
		},
		methods:{
			// 保存手机号
			submitEvent(){
				if(this.phoneNum == ''){
					uni.showToast({
						title:"请输入手机号",
						duration:2000,
						icon:"none"
					})
					return
				}
				if(this.oldPwd == ''){
					uni.showToast({
						title:"请输入旧密码",
						duration:2000,
						icon:"none"
					})
					return
				}
				if(this.newPwd == ''){
					uni.showToast({
						title:"请输入新密码",
						duration:2000,
						icon:"none"
					})
					return
				}
				const data = {
					oldPassword:this.oldPwd,
					newPassword:this.newPwd
				}
				this.$request({
					method: 'post',
					url: '/applet/store/shopEmployee/updatePassword',
					data,
					loading: false,
					isEncrypt: false
				}).then(res => {
					if(res.code == 500){
						uni.showToast({
							title:res.msg,
							duration:2000,
							icon:"none"
						})
					}else{
						uni.showToast({
							title:'修改成功，请重新登录',
							duration:2000,
							icon:"none"
						})
						uni.removeStorageSync('token')
						uni.removeStorageSync('password')
						setTimeout(()=>{
							uni.reLaunch({
								url:'/pages/login/login'
							})
						},2000)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
  .login-page{
	  background: #FFF;
	  padding: 40rpx;
	  box-sizing: border-box;
	  
	  .login-title{
		  font-weight: bold;
		  font-size: 48rpx;
		  color: #333333;
	  }
	  
	  .login-box{
		  .is-input-border{
			  border: none !important;
			  border-bottom: 1px solid #EEE !important;
			  border-radius: 0 !important;
		  }
		  
		  .uni-easyinput__content-input{
			    padding-left: 0 !important;
				font-size: 32rpx;
		  }
		  
		  .uni-easyinput__placeholder-class{
			  font-size: 32rpx !important;
		  }
		  
		  .uni-easyinput{
			  margin-top: 50rpx;
		  }
		  
		  .code-text{
			  font-size: 30rpx;
			  color: #ffd589;
			  font-size: 30rpx;
		  }
	  }
	  
	  .login-btn{
		  background: #ffd589;
		  border-radius: 45rpx;
		  font-size: 32rpx;
		  color: #000;
		  padding: 30rpx;
		  text-align: center;
		  margin-top: 100rpx;
	  }
	  
	  .is-login{
		   opacity: 1;
	  }
	  
	  .title-text{
	  		  font-size: 28rpx;
	  		  margin-top: 60rpx;
	  }
  }
</style>
